﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;

namespace CKNetFrameWork
{
    public partial class Frm_Order : DockContent
    {
        private LSY.BLL.LSY_OrderTab m_bllLSY_OrderTab = new LSY.BLL.LSY_OrderTab();

        private void ShowAllRecordInDataGridView(string strWhere)
        {
            ultraGrid1.DataSource = null;
            DataSet ds = m_bllLSY_OrderTab.GetListInfo(strWhere);

            ultraGrid1.DataSource = ds.Tables[0];
            ultraGrid1.DisplayLayout.Bands[0].Columns[0].Hidden = true;

        }

        public Frm_Order()
        {
            InitializeComponent();
        }

        private void Frm_Order_Load(object sender, EventArgs e)
        {

        }

        private void buttonShowAll_Click(object sender, EventArgs e)
        {
            ShowAllRecordInDataGridView("");
        }

        private void button2_Click(object sender, EventArgs e)
        {

        }
     
        private void buttonNew_Click(object sender, EventArgs e)
        {

            try
            {
                LSY.Model.LSY_OrderTab modelLSY_OrderTab = new LSY.Model.LSY_OrderTab();
                int nNewBGPackTabID = m_bllLSY_OrderTab.GetMaxId();
                string strDate = System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString().PadLeft(2, '0') + System.DateTime.Now.Day.ToString().PadLeft(2, '0');

                modelLSY_OrderTab.LSY_OrderNo = strDate + nNewBGPackTabID.ToString();
                modelLSY_OrderTab.LSY_OrderSheetDate = System.DateTime.Now.Date;
                modelLSY_OrderTab.LSY_OrderState = 0;
                modelLSY_OrderTab.LSY_AgentTabID = Frm_Main.m_nLoginUserId;
                m_bllLSY_OrderTab.Add(modelLSY_OrderTab);
                ShowAllRecordInDataGridView("LSY_OrderTab.LSY_AgentTabID = '" + Frm_Main.m_nLoginUserId + "'");
                MessageBox.Show("添加新订单成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString(), "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);

            }
        }
    }
}
